package main.java.jvm;

public class T02_CacheLinePadding {
    private volatile long p1,p2,p3,p4,p5,p6,p7;

    private static class T extends  T02_CacheLinePadding{
        public volatile long x = 0L;
    }
    public static T[] arr = new T[2];

    static {
        arr[0] = new T();
        arr[1] = new T();
    }

    public static void main(String[] args) throws InterruptedException {
        Thread t3 = new Thread(() -> {
            for (int i = 0; i < 1000_0000L; i++) {
                arr[0].x++;
            }
        }, "A");

        Thread t4 = new Thread(() -> {
            for (int i = 0; i < 1000_0000L; i++) {
                arr[1].x++;
            }
        }, "B");
        long start = System.nanoTime();
        t3.start();
        t4.start();

        t3.join();
        t4.join();

        System.out.println((System.nanoTime() - start)/100_0000L);
    }

}
